package cn.com.weather.nf.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.filter.CharacterEncodingFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@FilterRegistrationBean
@WebFilter(filterName="myCharacterEncodingFilter",urlPatterns="/*")
public class MyCharacterEncodingFilter extends CharacterEncodingFilter {

    static final Logger LOGGER = LoggerFactory.getLogger(MyCharacterEncodingFilter.class);

    public MyCharacterEncodingFilter() {
        LOGGER.info("MyCharacterEncodingFilter >>>>>>>>>>>>>>>>> ...{}", System.currentTimeMillis());
    }

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {

        LOGGER.info("before character eocoding ...{}", System.currentTimeMillis());
        super.doFilterInternal(request, response, filterChain);
        LOGGER.info("after character eocoding ...", System.currentTimeMillis());
    }
}
